package com.example.feed.multichannel;

import android.content.Context;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.feed.R;
import com.example.uiframework.utils.Utils;

public class ImageTextCard extends BaseCard {
    LinearLayout mContainer;
    ImageView mIvThumbnail;
    TextView mTvTitle;

    public ImageTextCard(@NonNull Context context) {
        super(context);
        mContainer = new LinearLayout(getContext());
        mContainer.setOrientation(LinearLayout.VERTICAL);
        LayoutParams lpContainer = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lpContainer.topMargin = lpContainer.bottomMargin = Utils.res.dpI(8);
        lpContainer.leftMargin = lpContainer.rightMargin = Utils.res.dpI(12);
        this.addView(mContainer, lpContainer);
        mTvTitle = new TextView(getContext());
        mTvTitle.setTextColor(0xff333333);
        mTvTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        mTvTitle.setMaxLines(2);
        mContainer.addView(mTvTitle);
        mIvThumbnail = new ImageView(context);
        mContainer.addView(mIvThumbnail, ViewGroup.LayoutParams.MATCH_PARENT, Utils.res.dpI(80));
    }


    @Override
    public void onBind(int position, BaseCardData data) {
        mTvTitle.setText(data.title);
        mIvThumbnail.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher_foreground));
    }
}
